import { defineComponent } from 'vue';
import tools from '@/utils/tools/index.js'

const shareParams = { title: '', desc: '', imageUrl: '' };
uni.$u = { inviteCode: '', shareParams, currentShareParams: shareParams };

export default defineComponent({
	methods: {
		getShareParams() {
			const data = tools.deepCopy(uni.$u.shareParams);
			console.log(data);
			for (let [key, value] of Object.entries(uni.$u.currentShareParams)) {
				if (value) data[key] = value;
			}
			return data;
		},
		mpShareMessage() {
			// title, path, imageUrl
			const { title, imageUrl } = this.getShareParams();
			console.log({ title, imageUrl });
			return { title, imageUrl }
		},
		mpShareTimeline() {
			// title,  query, imageUrl
			const { title, imageUrl } = this.getShareParams();
			console.log({ title, imageUrl });
			return { title, imageUrl }
		}
	},
	onShareAppMessage() {
		return this.mpShareMessage()
	},
	onShareTimeline() {
		return this.mpShareTimeline()
	},
})